// 进入全屏函数
export function enterFullscreen(element) {
    // 检查是否支持全屏 API
    if (element.requestFullscreen) {
        element.requestFullscreen();
    } else if (element.webkitRequestFullscreen) { // Webkit 内核（Chrome/Safari）
        element.webkitRequestFullscreen();
    } else if (element.mozRequestFullScreen) { // Firefox
        element.mozRequestFullScreen();
    } else {
        alert('您的浏览器不支持全屏功能');
    }
}

// 退出全屏函数
export function exitFullscreen() {
    if (document.exitFullscreen) {
        document.exitFullscreen();
    } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    }
}

// 监听 Esc 键退出全屏
document.addEventListener('keydown', (e) => {
    if (e.key === 'Escape' && document.fullscreenElement) {
        exitFullscreen();
    }
});

// 监听全屏状态变化（可选，用于日志或状态提示）
document.addEventListener('fullscreenchange', () => {
    if (document.fullscreenElement) {
        console.log('进入全屏');
    } else {
        console.log('退出全屏');
    }
});